
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier, export_text

# Load dataset
data = load_iris()
X, y = data.data, data.target

# Create and train the decision tree classifier
clf = DecisionTreeClassifier()
clf.fit(X, y)

# Display the decision tree rules
tree_rules = export_text(clf, feature_names=data.feature_names)
print(tree_rules)